#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Cisco::ShowRun < Aio::Module::Cmd::Cisco
  include Aio::Module

  def initialize
    super({
      :cmd_full 		=> "show run",
      :cmd_short 		=> "sh run",
      :author				=> "Elin",
      :description  => "This is Cisco Command# show run",
      :key_stand  	=> true,
      :platform			=> "all"
    })
  end

  #
  # 此模块暂时只支持将show run中的接口信息提取出来，不做任何处理
  #
  def parse
    context = self.context.dup
    iface_config = {}
    useful[:iface_config] = iface_config

    # NOTE 删除
    context.readline_match_block(/Building configuration/) do |block|
      key_stand_cisco
    end

    context.readline_range_loop(/interface (Fast|Gigabit)Ethernet/, reg_separator) do |cont|
      iface_name = cont.shift.split(' ')[1]
      iface_cont = cont.join("\n")

      iface_config[iface_name] = iface_cont
    end
  end
end

